package test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Admin
 */
public class Const {

    // Maximum degree = 4
    // Signature D1 and resulting D0 
    public static final ArrayList<Signature> SIG_1;

    // Signature D1, D2 and resulting D0
    public static final ArrayList<Signature> SIG_2;

    // Signature D1, D2, D3 and resulting D0
    public static final ArrayList<Signature> SIG_3;

    public static final Map<Integer, ArrayList<Integer[]>> SINGLE_SIG;
    public static final ArrayList<Integer[]> NOT_SINGLE_SIG;

    static {
        SIG_1 = new ArrayList<Signature>();
        SIG_1.add(new Signature(new Integer[]{1}, 2));
        SIG_1.add(new Signature(new Integer[]{2}, 1));
        SIG_1.add(new Signature(new Integer[]{3}, 1, 2));
        SIG_1.add(new Signature(new Integer[]{4}, 1, 2));

        SIG_2 = new ArrayList<Signature>();
        SIG_2.add(new Signature(new Integer[]{1, 1}, 1, 3));
        SIG_2.add(new Signature(new Integer[]{1, 2}, 2, 3));
        SIG_2.add(new Signature(new Integer[]{1, 3}, 1, 2));
        SIG_2.add(new Signature(new Integer[]{1, 4}, 1, 2, 3));
        SIG_2.add(new Signature(new Integer[]{2, 2}, 3));
        SIG_2.add(new Signature(new Integer[]{2, 3}, 2));
        SIG_2.add(new Signature(new Integer[]{2, 4}, 2, 3));
        SIG_2.add(new Signature(new Integer[]{3, 3}, 1, 2));
        SIG_2.add(new Signature(new Integer[]{3, 4}, 1, 2));
        SIG_2.add(new Signature(new Integer[]{4, 4}, 1, 2, 3));

        SIG_3 = new ArrayList<Signature>();
        SIG_3.add(new Signature(new Integer[]{1, 1, 1}, 1, 2, 4));
        SIG_3.add(new Signature(new Integer[]{1, 1, 2}, 1, 3, 4));
        SIG_3.add(new Signature(new Integer[]{1, 1, 3}, 2, 3, 4));
        SIG_3.add(new Signature(new Integer[]{1, 1, 4}, 1, 2, 3));
        SIG_3.add(new Signature(new Integer[]{1, 2, 2}, 1, 3, 4));
        SIG_3.add(new Signature(new Integer[]{1, 2, 3}, 3, 4));
        SIG_3.add(new Signature(new Integer[]{1, 2, 4}, 1, 3));
        SIG_3.add(new Signature(new Integer[]{1, 3, 3}, 2, 4));
        SIG_3.add(new Signature(new Integer[]{1, 3, 4}, 2, 3));
        SIG_3.add(new Signature(new Integer[]{1, 4, 4}, 1, 2, 3));
        SIG_3.add(new Signature(new Integer[]{2, 2, 2}, 1, 3, 4));
        SIG_3.add(new Signature(new Integer[]{2, 2, 3}, 3, 4));
        SIG_3.add(new Signature(new Integer[]{2, 2, 4}, 1, 3));
        SIG_3.add(new Signature(new Integer[]{2, 3, 3}, 4));
        SIG_3.add(new Signature(new Integer[]{2, 3, 4}, 3));
        SIG_3.add(new Signature(new Integer[]{2, 4, 4}, 1, 3));
        SIG_3.add(new Signature(new Integer[]{3, 3, 3}, 2, 4));
        SIG_3.add(new Signature(new Integer[]{3, 3, 4}, 2));
        SIG_3.add(new Signature(new Integer[]{3, 4, 4}, 2, 3));
        SIG_3.add(new Signature(new Integer[]{4, 4, 4}, 1, 2, 3));

        SINGLE_SIG = new HashMap<Integer, ArrayList<Integer[]>>();
        NOT_SINGLE_SIG = new ArrayList<Integer[]>();
        initSingleSignature(SIG_1, SIG_2, SIG_3);

    }

    static void initSingleSignature(ArrayList<Signature>... list) {
        for (ArrayList<Signature> sig : list) {
            for (Signature signature : sig) {
                if (signature.result.size() == 1) {
                    int key = signature.result.iterator().next();

                    if (!SINGLE_SIG.containsKey(key)) {
                        SINGLE_SIG.put(key, new ArrayList<Integer[]>());
                    }
                    SINGLE_SIG.get(key).add(signature.sequence);
                } else {
                    NOT_SINGLE_SIG.add(signature.sequence);
                }
            }
        }
    }

}
